1 Public Class FrmPOSPAYMENT
2 Dim timx As Integer
3 Dim xSales_ID As Integer
4 Private mReport As New CrystalDecisions.CrystalReports.Engine.ReportDocument
5 Private Sub cmdCancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdCancel.Click
6 Me.Close()
7 End Sub
8
9
10 Private Sub txtcashreceive_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtcashreceive.TextChanged
11 txtcashreceive.Text = str_Filter(txtcashreceive, 48, 57, 46, 1)
12 'If txtcashreceive.Text = "" Then txtcashreceive.Text = "0"
13 'txtcashchange.Text = Format(CDbl(txtcashreceive.Text) - CDbl(lblamountdue.Text), "###,###.00")
14
15 If txtcashreceive.Text = "" Then
16 txtcashchange.Text = Format(0 - CDbl(lblamountdue.Text), "###,###.00")
17 Else
18 txtcashchange.Text = Format(CDbl(txtcashreceive.Text) - CDbl(lblamountdue.Text), "###,###.00")
19 End If
20 End Sub
21
22 Private Sub FrmPOSPAYMENT_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
23 'Dim i As Integer
24 txtcashchange.Text = "0.00"
25 txtcashreceive.Text = ""
26 timx = 0
27 'For i = 0 To UBound(xid)
28 'MsgBox(UBound()
29 'MsgBox(xid(i))
30 'Next
31 End Sub
32
33 Private Sub cmdOk_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdOk.Click
34 Dim i As Integer
35 Dim SQLStrx(0) As String
36 With FrmPOSCASHIER
37 If Int(txtcashchange.Text) < 0 Then
38 MsgBox("Insufficient Cash Amount Receive !!", MsgBoxStyle.Critical, "Sales and Inventory")
39 txtcashreceive.Focus()
40 txtcashreceive.Select()
41 Exit Sub
42 End If
43 If .lstItems.Items.Count > 0 Then
44 If .cmbSelectType.SelectedIndex = 0 Then
45 sqlSTR = "SELECT *, * " & _
46 "FROM TBL_Sales_Receipt " & _
47 "INNER JOIN TBL_Sales_Sold_Detail ON TBL_Sales_Receipt.Sales_ID = TBL_Sales_Sold_Detail.Sales_ID " & _
48 "WHERE TBL_Sales_Receipt.Sales_ID NOT IN (SELECT Sales_ID FROM TBL_Sales_Void) " & _
49 "AND Order_No =" & .txtbarcode.Text
50
51 ExecuteSQLQuery(sqlSTR)
52 If sqlDT.Rows.Count > 0 Then
53 xSales_ID = sqlDT.Rows(0)("Sales_ID")
54 For i = 0 To sqlDT.Rows.Count - 1
55 'MsgBox(sqlDT.Rows(i)("Item_ID"))
56 ReDim Preserve SQLStrx(i)
57 SQLStrx(i) = "UPDATE TBL_Stocks_Balances SET Item_QTY = Item_QTY - " & sqlDT.Rows(i)("Item_QTY") & _
58 " WHERE Item_ID = " & sqlDT.Rows(i)("Item_ID")
59
60 Next
61 For i = 0 To UBound(SQLStrx)
62 ExecuteSQLQuery(SQLStrx(i))
63 Next
64 ''Exit Sub
65 sqlSTR = "DELETE FROM TBL_Sales_Receipt WHERE Order_No =" & .txtbarcode.Text
66 ExecuteSQLQuery(sqlSTR)
67 sqlSTR = "DELETE FROM TBL_Sales_Sold_Detail WHERE Sales_ID =" & xSales_ID
68 ExecuteSQLQuery(sqlSTR)
69 sqlSTR = "DELETE FROM TBL_Sales_Sold WHERE Sales_ID =" & xSales_ID
70 ExecuteSQLQuery(sqlSTR)
71 Else
72 For i = 0 To FrmPOSCASHIER.lstItems.Items.Count - 1
73 ReDim Preserve SQLStrx(i)
74 SQLStrx(i) = "UPDATE TBL_Stocks_Balances SET Item_QTY = Item_QTY - " & FrmPOSCASHIER.lstItems.Items(i).SubItems(4).Text & _
75 " WHERE Item_ID = " & FrmPOSCASHIER.lstItems.Items(i).Text
76 Next
77 For i = 0 To UBound(SQLStrx)
78 ExecuteSQLQuery(SQLStrx(i))
79 Next
80 End If
81 End If
82 sqlSTR = "INSERT INTO TBL_Sales_Sold (Sales_Date, Amount_Due, Amount_Receive, Amount_Change, Order_No) " & _
83 "VALUES ('" & .lbldate.Text & "', " _
84 & CDbl(lblamountdue.Text) & ", " _
85 & CDbl(txtcashreceive.Text) & ", " _
86 & IIf(CDbl(txtcashchange.Text) > 0, CDbl(txtcashchange.Text), 0) & ", " _
87 & IIf(.cmbSelectType.SelectedIndex = 0, .txtbarcode.Text, 0) & ")"
88
89 'add to tbl_sales_sold_Detail
90 ExecuteSQLQuery(sqlSTR)
91 sqlSTR = "SELECT * FROM TBL_Sales_Sold ORDER BY Sales_ID DESC"
92 ExecuteSQLQuery(sqlSTR)
93 If sqlDT.Rows.Count > 0 Then
94 'pass id
95 xSales_ID = sqlDT.Rows(0)("Sales_ID")
96 ' MsgBox(xSales_ID)
97 End If
98 For i = 0 To FrmPOSCASHIER.lstItems.Items.Count - 1
99 sqlSTR = "INSERT INTO TBL_Sales_Sold_Detail (Sales_ID, Item_ID, Item_Name, Item_Description, Item_Price, Item_Qty, Total_Price, Added_QTY) " & _
100 "VALUES (" & xSales_ID & ", " _
101 & .lstItems.Items(i).Text & ", " _
102 & "'" & R_eplace(.lstItems.Items(i).SubItems(1).Text) & "', " _
103 & "'" & R_eplace(.lstItems.Items(i).SubItems(2).Text) & "', " _
104 & CDbl(.lstItems.Items(i).SubItems(3).Text) & ", " _
105 & .lstItems.Items(i).SubItems(4).Text & ", " _
106 & CDbl(.lstItems.Items(i).SubItems(3).Text) * CDbl(.lstItems.Items(i).SubItems(4).Text) & ", " _
107 & 0 & ")"
108 ExecuteSQLQuery(sqlSTR)
109
110 'UPDATE STOCKS
111 If .cmbSelectType.SelectedIndex <> 0 Then
112 sqlSTR = "UPDATE TBL_Stocks_Balances SET Item_QTY =" & " Item_QTY - " & .lstItems.Items(i).SubItems(4).Text & " WHERE Item_ID = " & .lstItems.Items(i).Text
113 ExecuteSQLQuery(sqlSTR)
114 End If
115 Next
116 'Create Receipt
117 sqlSTR = "INSERT INTO TBL_Sales_Receipt " & _
118 "(Sales_ID, VATable, VAT_Exempt_Sale, " & _
119 "Total_Sale, Amount_Due, Receipt_Date, VAT, " & _
120 "Void, User_ID, Order_No) " & _
121 "VALUES (" & xSales_ID & ", " _
122 & CDbl(.txtvatable.Text) & ", " _
123 & CDbl(.txtvatexempt.Text) & ", " _
124 & CDbl(.txttotalsale.Text) & ", " _
125 & CDbl(.txtamountdue.Text) & ", " _
126 & "'" & .lbldate.Text & "', " _
127 & CDbl(.txtvat12.Text) & ", " _
128 & "'" & "No" & "', " _
129 & xUser_ID & ", " _
130 & IIf(.cmbSelectType.SelectedIndex = 0, .txtbarcode.Text, 0) & ")"
131 ExecuteSQLQuery(sqlSTR)
132 Else
133 MsgBox("No item in the list !!", MsgBoxStyle.Exclamation, "Sales and Inventory")
134 Exit Sub
135 End If
136 Audit_Trail(xUser_ID, TimeOfDay, "Print New Sales Receipt Receipt No : " & xSales_ID)
137 MsgBox("Purchase Success !!", MsgBoxStyle.Information, "Sales and Inventory")
138 Timer1.Enabled = True
139 'IIf(.cmbSelectType.SelectedIndex = 0, .txtbarcode.Text = "0", .txtbarcode.Text = "")
140 '.lblbarcode.Text = ""
141 If .cmbSelectType.SelectedIndex = 0 Then
142 .txtbarcode.Text = "0"
143 Else
144 .txtbarcode.Text = ""
145 End If
146 .lbltotalamount.Text = ""
147 .txttotalsale.Text = ""
148 .txtvat12.Text = ""
149 .txtvatable.Text = ""
150 .txtvatexempt.Text = "0.00"
151 .txtamountdue.Text = "0"
152 '.txtDiscount.Text = "0"
153 '.txttotalamountdue.Text = "0"
154 .lstItems.Items.Clear()
155 'check critical product
156
157 With MDIMain
158 If UCase(xUser_Access) = UCase("administrator") Or UCase(xUser_Access) = UCase("Sales Agent") Or UCase(xUser_Access) = UCase("Stock Room") Then
159 sqlSTR = "SELECT TBL_Category_Item_File.Item_ID as 'ID', Replace(Replace(Item_Name,'$.$',''''),'$..$',',') as 'Name', TBL_Category_Item_File.Item_Description as 'Description', TBL_Stocks_Balances.Item_Price as 'Price', Item_Reorder_Point as 'Reorder Point', Item_QTY as 'CURRENT STOCKS' " & _
160 "FROM TBL_Category_Item_File INNER JOIN " & _
161 "TBL_Stocks_Balances ON TBL_Category_Item_File.Item_ID = TBL_Stocks_Balances.Item_ID " & _
162 "WHERE TBL_Stocks_Balances.Item_QTY <= Item_Reorder_Point"
163 ExecuteSQLQuery(sqlSTR)
164
165 If sqlDT.Rows.Count > 0 Then
166 MsgBox("A Product(s) reach its critical level !!", MsgBoxStyle.Exclamation, "Sales and Inventory")
167 .tmrcritical.Enabled = True
168 With FrmPOSCASHIER
169 .Timer1.Enabled = True
170 End With
171 Else
172 .tmrcritical.Enabled = False
173 .cmdProductReorder.ForeColor = Color.Black
174 With FrmPOSCASHIER
175 .Timer1.Enabled = False
176 .lblreach.Visible = False
177 End With
178 End If
179 Else
180 .cmdProductReorder.ForeColor = Color.Black
181 sqlSTR = "SELECT TBL_Category_Item_File.Item_ID as 'ID', Replace(Replace(Item_Name,'$.$',''''),'$..$',',') as 'Name', TBL_Category_Item_File.Item_Description as 'Description', TBL_Stocks_Balances.Item_Price as 'Price', Item_Reorder_Point as 'Reorder Point', Item_QTY as 'CURRENT STOCKS' " & _
182 "FROM TBL_Category_Item_File INNER JOIN " & _
183 "TBL_Stocks_Balances ON TBL_Category_Item_File.Item_ID = TBL_Stocks_Balances.Item_ID " & _
184 "WHERE TBL_Stocks_Balances.Item_QTY <= Item_Reorder_Point"
185 ExecuteSQLQuery(sqlSTR)
186 With FrmPOSCASHIER
187 If sqlDT.Rows.Count > 0 Then
188
189 .Timer1.Enabled = True
190
191 Else
192 .Timer1.Enabled = False
193 .lblreach.Visible = False
194
195 End If
196 End With
197 End If
198 End With
199 Me.Close()
200 End With
201 xpass = False
202 howx = 0
203 End Sub
204
205 Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
206 Dim Report As New FrmREPORTS
207 timx = timx + 1
208 If timx >= 4 Then
209 ' Rpt_SqlStr = "SELECT * FROM TBL_Sales_Sold_Detail WHERE Sales_ID =" & xSales_ID & _
210 ' "SELECT * FROM TBL_Globaldata"
211 Timer1.Enabled = False
212 Rpt_SqlStr = "SELECT * FROM TBL_Sales_Sold_Detail WHERE Sales_ID =" & xSales_ID
213 'MsgBox(Rpt_SqlStr)
214 globalFRM = "frmPOSPAYMENT"
215 Report.Show()
216 'FrmREPORTS.Show()
217 '--
218 'mReport.Load(Application.StartupPath & "\ReportX\Receipt_Rpt.rpt")
219 'mReport.SetDataSource(ExecuteSQLQuery(Rpt_SqlStr))
220 'mReport.PrintToPrinter(1, True, 1, 1)
221
222
223 End If
224 End Sub
225
226 Private Sub txtcashchange_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtcashchange.TextChanged
227
228 End Sub
229 End Class